package com.example.applicationview.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

import com.example.applicationview.R;

/**
 * 利用mPaint.setMaskFilter，绘制发光效果，可用于 发光背景
 */
public class MaskFilterView extends BaseView {
    public MaskFilterView(Context context) {
        super(context);
        init();
    }

    public MaskFilterView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init(){
        setLayerType( LAYER_TYPE_SOFTWARE , null);
//        mPaint.setColor(Color.GREEN);
        mPaint.setTextSize(25);
    }

//    public void changeDy() {
//        mDy+=5;
//        postInvalidate();
//    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

//        mPaint.setShadowLayer(mRadius, mDx, mDy, Color.GRAY);

        //只显示外部的发光区域
        mPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.OUTER));

//        canvas.drawText("启舰大SB",100,100,mPaint);
//        canvas.drawCircle(200,200,50,mPaint);

        Rect rect = new Rect(20 , 20 , mWidth - 20, mHeight-20);
        canvas.drawRect(rect, mPaint);

    }
}